#include <stdio.h>
#include <math.h>

typedef struct { double x, y; } Point;

/* Returns the square of Euclidean distance between two points. */
double distance_squared(const Point P1, const Point P2)
{
    double dx = P1.x - P2.x;
    double dy = P1.y - P2.y;
    return dx * dx + dy * dy;
}

/* Returns the Euclidean distance between two points. */
double distance(const Point P1, const Point P2)
{
    double dx = P1.x - P2.x;
    double dy = P1.y - P2.y;
    return sqrt(dx * dx + dy * dy);
}

#define MAX_SEGMENTS    10
#define MAX_TOWERS      10
#define MARKER_INTERVAL 1

static Point towers[MAX_TOWERS];     /* location of the towers */
static int power[MAX_TOWERS];        /* power of each tower */
static Point points[MAX_SEGMENTS+1]; /* knot points of the road */
static int num_towers, num_segments;

/* Returns the tower with strongest signal for a user at location loc. */
static int tower_of_choice(const Point loc)
{
    int i, choice = 0;
    double best = 0;
    for (i = 0; i < num_towers; i++)
    {
        double p = power[i] / distance_squared(loc, towers[i]);
        if (p > best)
        {
            best = p;
            choice = i;
        }
    }
    return choice;
}

static void solve()
{
    int last_choice;    /* last tower of choice */
    int choice;         /* current tower of choice */
    double extra = 0;   /* distance walked since previous marker */
    int marker = 0;     /* the marker just passed */
    int k;              /* index of next point ahead */

    last_choice = choice = tower_of_choice(points[0]);
    printf("(0,%c)", choice + 'A');

    for (k = 1; k <= num_segments; k++)
    {
        /* Move to the next marker on this road segment. */
        double d = distance(points[k-1], points[k]);
        double dx = (points[k].x - points[k-1].x) / d;
        double dy = (points[k].y - points[k-1].y) / d;

        Point loc = points[k-1];    /* location of the traveller */
        while (d + extra >= MARKER_INTERVAL)
        {
            loc.x += (MARKER_INTERVAL - extra) * dx;
            loc.y += (MARKER_INTERVAL - extra) * dy;
            marker++;
            d -= (MARKER_INTERVAL - extra);
            extra = 0;
            choice = tower_of_choice(loc);
            if (choice != last_choice)
            {
                printf(" (%d,%c)", marker, choice + 'A');
                last_choice = choice;
            }
        }
        extra += d;
    }

    if (extra >= 0.5)
    {
        marker++;
        choice = tower_of_choice(points[num_segments]);
        if (choice != last_choice)
            printf(" (%d,%c)", marker, choice + 'A');
    }

    printf("\n");
}

int main()
{
    while (scanf("%d %d", &num_towers, &num_segments) == 2)
    {
        int i, x, y;
        for (i = 0; i < num_towers; i++)
        {
            scanf("%d %d %d", &x, &y, &power[i]);
            towers[i].x = x;
            towers[i].y = y;
        }
        for (i = 0; i <= num_segments; i++)
        {
            scanf("%d %d", &x, &y);
            points[i].x = x;
            points[i].y = y;
        }
        solve();
    }
    return 0;
}
